home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / gip_02.zip / GIP-SYSP.DOC < prev    next >
Text File  |  1994-12-18  |  21KB  |  523 lines

  1. Graphic Interchange Protocol (GIP) Technical Standards -- Request For Comment
  2. Document #1 release .02
  3.  
  4. New stuff since .01 has a "│" as the first character of the line.
  5.  
  6. Using GIP with GIP compatible BBS's--the sysop's viewpoint.
  7.  
  8.  
  9. OVERVIEW
  10.  
  11.   Advantages of GIP
  12.  
  13.     Open architecture for future expandability.
  14.     Single-pass optimized communications.
  15.     Public domain source code.
  16.     Automatic updating protocol for graphic files.
  17.     GIP codes work just like ANSI codes.
  18.     Object definition ability.
  19.  
  20.   Disadvantages of GIP
  21.  
  22.     Reliance on a public, changing, standard.
  23.  
  24.   Comparison with other methods
  25.  
  26.     The fastest general-BBS protocol.
  27.     Requires no licensing fees.
  28.     Requires little code development.
  29.     Uses current utilities for graphic creations.
  30.     Easy to implement, design, and alter graphics on the BBS.
  31.     Support for SVGA modes.
  32.  
  33.  
  34. HOW IT WORKS
  35.  
  36.   GIP commands, like ANSI commands, are meant to be imbeded in text.  At the
  37.   lowest capability of the commands (drawing) you need nothing more than a
  38.   text editor.
  39.  
  40.   You cannot use ANSI codes along with GIP codes.
  41.  
  42.   The GIP code is ASCII 19, or "" (the double-exclaimation points).
  43.  
  44.   Like ANSI codes, you can put these codes into strings of text in the
  45.   program itself.  And can use an editor to create them (well, at least
  46.   PC-Write does let you).
  47.  
  48.   It's a simple system:
  49.     <><Do what ID letter><What to do stuff><;>
  50.  
  51.   The user does need to have a GIP compatible communications program to
  52.   view your creations.
  53.  
  54.   The software handles everything about the exchange.  You need not worry
  55.   about how it does what it does, how users store/update the data, or whether
  56.   they can do the commands or handle the level of graphics.  You need only
  57.   design what you want users to see.
  58.  
  59.   You do not need to make an archive of your graphics available for users
  60.   to download.
  61.  
  62.   Any "hot" keys (such as menu command keys) are not valid as the graphics
  63.   are being displayed.  This is done so both sides stay in sync about the
  64.   graphics/text being displayed.
  65.  
  66.  
  67. COMMANDS
  68.  
  69.   h and v are coordinates.  These go from 0 to N - 1 (N depends on the
  70.   graphics mode).  0,0 is the upper-left corner of the screen.  The
  71.   numbers are integers (0, 1, 2, 3, etc.)   "h" are the cordinates along
  72.   the line (horizontal coordinates), and "v" are the vertical (up/down)
  73.   coordinates.
  74.  
  75.   d is the depth for 3-D, and isn't coded for yet.
  76.  
  77.   The h,v,d values may either represent actual screen coordinates, or
  78.   offsets from the last-used coordinate, command dependent.  When they are
  79.   offset values, negative numbers can be used.  A "0" offset value means to
  80.   draw at least one pixel--since you are drawing from the current pixel to
  81.   pixel location + 0.
  82.  
  83.   n is a number, and its values are also command dependent.
  84.  
  85.  
  86.   COMMAND   DESCRIPTION
  87.  
  88.  
  89.   Sn;       Switch to graphics mode n.
  90.  
  91.             Where n is:  0 for standard 80x25 mode.
  92.                          1 for 320x200x4 CGA (testing mode only).
  93.                          2 for 640x480x16 VGA.
  94.                          3 for 320x200x256 VGA.
  95.                          4 for 640x480x256 SVGA.
  96.                          5 for 800x600x256 SVGA.
  97.  
  98.             Example:  S2;
  99.                       Begins graphic mode 2.
  100.                       S0;
  101.                       Returns back to normal (ANSI) mode.
  102.  
  103.             Modes 4 and 5 require an SVGA card, and are a bit less-automatic
  104.             for beginner users.  For general-audience graphics, you should
  105.             stick with modes 2 and 3.
  106.  
  107.             Mode 2 provides for 80x60x16 text.  While Mode 4 only provides
  108.             for 40x25x256 text.
  109.  
  110.             For normal operations, mode 2 is the only real practical mode.
  111.             It's drawback is that some sysops might find it's text a little
  112.             small.  This will be solved for in the future when I add support
  113.             for more fonts.
  114.  
  115. │           This acts as CLS: it clears the screen, and resets the h,v,d
  116. │           current coordinates to 0,0,0.  It also sets the color to 15,
  117. │           which is bright white in 640x480x16 mode.  Finally, the line
  118. │           pattern is also reset to that of a solid line.
  119.  
  120. │           An Sn; code will always start a GIP session.  That is, you
  121. │           cannot do "Cn;Sn;" and expect the software to act on the
  122. │           Cn;, since it's before we went into GIP mode, and will be
  123. │           ignored.
  124.  
  125.  
  126.   Cn;       Switch to color n.
  127.  
  128.             Where n is:  0 to 15
  129.                          0 to 255
  130.  
  131.             Example:  C0;
  132.                       Change the current color to black.
  133.  
  134.             This depends on what mode you are in (either 16 or 256 colors).
  135.             The 16 color mode follows the same color scheme as ANSI does.
  136.  
  137.  
  138.   Gh,v,d;   Go to point h,v,d.
  139.  
  140.             Example:  G10,10,0;
  141.                       will move to graphics location 10,10.
  142.  
  143.             Nothing is displayed.
  144.  
  145.             h,v,d cannot be negative numbers.
  146.  
  147.             This is the most used command, as it's used to place lines,
  148.             boxes, and text.
  149.  
  150.  
  151.   Mh,v,d;   Go to offset point h,v,d.
  152.  
  153.             Example:  G20,20,0;
  154.                       will move from the current location to offset 20,20.
  155.                       After the call, the new current location is 10,10 +
  156.                       the h,v offset (30,30).
  157.  
  158.             Nothing is displayed.
  159.  
  160.             This command is usually only used when defining objects, which
  161.             by their nature can't be screen coordinate dependant.
  162.  
  163.  
  164.   Lh,v,d;   Draw a line from current point to h,v,d.
  165.  
  166.             Example:  L20,20,0;
  167.                       will draw a line, in the current color, from the
  168.                       current location to offset 20,20.  After the call,
  169.                       the new current location is 10,10 + the h,v offset.
  170.  
  171.             There is no "draw a point" command.  To draw points, use very
  172.             short lines.
  173.  
  174.  
  175.   Bh,v,d;   Draw a rectangle from the current postition to h,v,d.  Where
  176.             h,v,d is the opposite corner of the rectangle.
  177.  
  178.             Example:  B20,20,0;
  179.                       will draw a line-box, in the current color, from the
  180.                       current location to offset 20,20.  After the call,
  181. │                     the current location is still 20,20,0.
  182.  
  183.  
  184.   Fh,v,d;   Draw a filled/solid rectangle from the current postition to
  185.             corner h,v,d.  Where h,v,d is the opposite corner of the rectangle.
  186.  
  187.             Example:  F20,20,0;
  188.                       will draw a filled box, in the current color, from the
  189.                       current location to offset 20,20.  After the call,
  190. │                     the current location is still 20,20,0.
  191.  
  192.             The current pattern is also used.
  193.  
  194.             If you're trying to draw a box over text, and you get "ghosting"
  195.             of the previous stuff in that area--that's a sure sign that you
  196.             forgot to reset your pattern to solid--that "ghosting" is pixels
  197.             being skipped due to the pattern.
  198.  
  199. │           Using a "skip pattern" like "01010101010101010101" will double
  200. │           the speed of the filled box display, with no noticable loss of
  201. │           color.  This technique is excellent for doing background patterns
  202. │           onto a black screen--since there is no reason for a background
  203. │           pattern to be solid rather than 50/50--they look nearly the same.
  204. │           But this trick cannot be used when writing over other colors, nor
  205. │           when the text you wish to put over this pattern is a dark black,
  206. │           blue, grey--as the extra black pixels will make it look fuzzy.
  207.  
  208.  
  209.   fPATHNAME;
  210.             The file exchange protocol.  The heart of GIP.  It is used to
  211.             send any files.  Including .GIF's, .ICO's, .MOD's, .VOC's, etc.
  212.             The software determines what to do with your file based on the
  213.             file's extension.  So if it's a GIF, use .GIF display, etc.
  214.  
  215.             Example:  fC:\BBS\NCD.ICO;
  216.                       would display C:\BBS\NCD.ICO with it's upper-left
  217.                       corner starting at the current location.
  218.                       fC:\BBS\METAL.VOC;
  219.                       would play C:\BBS\METAL.VOC.
  220.  
  221.             It's really an "update protocol"--since the file will not be
  222.             sent if the current version of the file already exists on the
  223.             callers disk in his "your BBS identifier" directory.
  224.  
  225.             The path is not sent, only the filename.
  226.  
  227.             We stay at the current coordinates--they are not changed.
  228.   
  229.             For now, only .ICO icon files are handled.  These are "standard"
  230.             766 byte sized 16-color icons.
  231.  
  232.             .BMP files also sort-of work.  Not in CGA mode, and the dark
  233.             colors are off with some BMP's.  Doesn't decode RLE compressed
  234.             BMPs either.
  235.  
  236.             Any other file you send will be sent, but will be assumed to be
  237.             a standard text or ANSI file and displayed as such.
  238.  
  239.             The exception is .BMP's.  However, the current code I have to 
  240.             display .BMP's displays them with the wrong colors.  I only
  241.             tell you now because sometimes it displays them properly (such
  242.             as most of the 16 color BMP colors).
  243.  
  244.  
  245.   Pn,s;     Set the "pattern" to use for drawing lines and filling boxes.
  246.  
  247.             Where n is:  0 to 65534
  248.                          -1 to 32767
  249.                          A 16 character pattern of 0's and 1's (example:
  250.                          0000111100001111).
  251.  
  252.             Where s is:  -15 to 15
  253.  
  254.             Example:  P1,0;
  255.                       or
  256.                       P0000000000000001,0;
  257.                       will use "               ∙" (15 blanks and then a
  258.                       dot) for the pattern for drawing lines, boxes, etc.
  259.  
  260.             The pattern is the same as formed by the ON/OFF bits of the
  261.             number n, with an ON bit being a visible pixel, and an OFF
  262.             bit being a skipped pixel.
  263.  
  264.             An exception is zero, this is changed to "-1" or "65534" and is
  265.             equivalent to a solid line of pixels.  I did this to make it
  266.             easier to work with, and because "all pixels off" lines aren't
  267.             likely to be needed.
  268.  
  269.             The default is a solid line, and this default is selected each
  270.             time you change the screen mode.  Otherwise the pattern defined
  271.             stays in effect until you do a new pattern-change or another
  272.             screen mode change.
  273.  
  274.             At the start of each line drawing order, we begin with the left-
  275.             most pixel, and continue on through to the right.  Starting again
  276.             at the left after the 16th pixel.
  277.  
  278.             The exception to this is filled boxes.  In order to avoid 
  279.             streaking lines, we incorpate "s"--the shift value.  After each
  280.             line when drawing a filled box, the bit pattern will be shifted
  281.             according to s.  A negative value means to rotate left, a
  282.             positive value means to rotate right, a zero means no shifting.
  283.  
  284.             For example, for the "on-off-on-off" pattern, no shifting would
  285.             yield not a pattern, but an organized set of vertical lines.  If
  286.             you shift more than one, you get organized slanted lines.  So the
  287.             shift you use depends on that pattern you use, and will probably
  288.             require a little trial and error.
  289.  
  290.  
  291.   On;~xxx~  Define an object for later display.
  292.  
  293.             Where n is:  0 to 255
  294.  
  295.             Example:  O1;~C3;G5,5,0;L15,5,0;L15,15,0;L5,15,0;L5,5,0;~
  296.                       Which defines Object #1 to be orders to: change to
  297.                       color 3 and goto 5,5 and draw a box.
  298.  
  299.             It's very flexible, you can have GIP codes and normal text
  300.             intermixed.
  301.  
  302.             It's not displayed at the time you define/send it.
  303.  
  304.             Only three restrictions:  no GIP "f<pathname>" commands nor other
  305.             object commands (either defining or using) should be inside the
  306.             two "~" characters.  And, of course, no "~" allowed inside the
  307.             definition.
  308.  
  309.             This is the cyberspace command, with which we will have
  310.             cyberspace in the future.
  311.  
  312.             When defining objects, the maximum size of any one object is
  313.             2048 bytes, and the size of all objects must not exceed 8192
  314.             bytes.  If you need to exceed these limits, I recommend using
  315.             either an icon or graphic image file.
  316.  
  317.  
  318.   on;       Call up and display/use an Object.
  319.  
  320.             Where n is:  0 to 255
  321.  
  322.             Example:  o1;
  323.                       Will display Object #1 we defined earlier.
  324.  
  325.             This offers fast graphics, since the commands do not have to
  326.             be re-sent each time you want to display the same thing.
  327.             It also offers the sysop convience.  When testing postioning
  328.             of GIP drawings, and when working with lots of the same
  329.             drawings.
  330.  
  331. ASCII TEXT
  332.  
  333.   Text is like lines--its pixels are drawn on top of whatever is there
  334.   already.  It uses whatever was the last defined color, at whatever was
  335.   the last location.
  336.  
  337.   For now, only an 8x8 font is used.  After each character is displayed,
  338.   we automatically add 8 to the orginal (pre-drawing) horizontal location,
  339.   which has the effect of putting us right where the next character would
  340.   be drawn.
  341.  
  342.   For spans of spaces, 8 or fewer spaces is more efficient than using a
  343.   "Gh,v,d;" command to move you ahead.
  344.  
  345.   For CR/LF's, we simply change the horizontal coordinate to zero, and add
  346.   8 to the vertical coordinate.  This allows us to display normal text going
  347.   down the screen normally.  However, there are problems when you reach the
  348.   end of the screen--as the there no scrolling in GIP (nor any wraparound to
  349.   the next lines).  Think of CR/LF's this way: just another cursor positioning
  350.   command: "go to start of next line".
  351.  
  352.   Usually the effects of CR/LF's do not matter.  They are very useful for
  353.   making GIP files readable.  So don't be afraid to use them for that purpose.
  354.  
  355.   The full 256 character ASCII set may be sent and displayed except for the
  356.   following codes: 10, 13, 19, 12, 22, 25, 27
  357.   These codes are used by ANSI, GIP, Avatar, and text to signify something
  358.   besides their normal ASCII character.
  359.  
  360.  
  361. EXAMPLES
  362.  
  363.   "S2;fC:\BBS\NODE001\GRA\PIC1.ICO;G300,300,0;Hi there!"
  364.  
  365.   will: clear the screen and go to graphics mode (S2;)
  366.         send the file PIC1.ICO (if the caller doesn't have it already)
  367.           (fC:\BBS\NODE001\GRA\PIC1.ICO;)
  368.         locate pixel 300,300 (G300,300,0;)
  369.         and display "Hi there!" at that point.
  370.  
  371.   "S2;G300,300,0;fC:\BBS\NODE001\GRA\PIC1.ICO;Hi there!"
  372.  
  373.   will: same as the above, but draws the icon at 300,300 and "Hi there!"
  374.         right after the icon.
  375.  
  376.  
  377. NOTES
  378.  
  379.   GIP codes, like ANSI, can be put into files and displayed.  I recommend
  380.   the extension .GIP (like .ANS) but it's not required.
  381.  
  382.   GIP contains no error-checking stuff, and so should only be used by MNP
  383.   modems (the baud doesn't matter).
  384.  
  385.  
  386. │PROBLEMS
  387. │  If for some reason things just are not being positioned where you expect,
  388. │  and no matter what you do does not seem to change it.  Chances are the
  389. │  problem is due to you forgetting about CR/LF's.
  390. │  At the end of each line, that CR/LF is noticed, and causes the Vertical
  391. │  position to get +8, and the Horizontal position to become 0.  CR/LF's
  392. │  are great for cleaning up a .GIP file, and very useful with text, but
  393. │  when working with mostly graphics, do not forget that it does alter the
  394. │  coordinates.
  395. │  Forgetting to turn off a pattern when drawing text causes the text to
  396. │  look sloppy.
  397. │  Another tricky problem when laying down a filled area of one pattern,
  398. │  and then putting another pattern (that isn't solid) on top of that.  If
  399. │  you were expecting the second pattern, you might be surprised to get
  400. │  something unexpected.  Because a few of those pixels from the first
  401. │  pattern will pass on through--enough to make a nice on/off pattern into
  402. │  a unwanted moire pattern.
  403. │  Other common problems include forgetting the double-quotation in front
  404. │  of a GIP command, or the semi-colon at the end of the command, or using
  405. │  semi-colons instead of commas inside the GIP command.
  406. │  When using dithered backgrounds (like on/off patterns) one thing you
  407. │  need to watch/play with is text colors that you put onto these areas.
  408. │  Because of the dithering, the dark spots, or light spots, can make the
  409. │  text look real fuzzy.
  410.  
  411.  
  412. CONVERTING TEXT FILES TO GIP
  413.  
  414.   For bare bones conversion of a standard text file to gip, there are only
  415.   two things to do:
  416.  
  417.     Add a "Sn;Cn;" at the start of the file.
  418.     Add a "S0;" at the end of the file.
  419.  
  420.  
  421. CONVERTING ANSI FILES TO GIP
  422.  
  423.   These are the steps to follow that to make conversi of ANSI's easier:
  424.  
  425.   First, convert the "[xC" "cursor jumping" commands to their spaces 
  426.   equivalent.  Example "[7C" becomes "       ".  You can optimize it with 
  427.   "Gh,v,d;" commands later.  A "Gh,v,d;" command uses 8 characters in it's 
  428.   transmission, so there is nothing to be gained by reducing gaps 8 or fewer 
  429.   characters to "Gh,v,d;" calls.
  430.  
  431.   Second, convert the "[x,y,zm" color commands.  Easy except for background 
  432.   commands "[44m"--in which case you'll probably want to first draw a filled
  433.   box of the length desired and then draw the characters on top of it.
  434.  
  435.   The above stuff on converting normal text files is useful too.
  436.  
  437.   0,8,16,24 etc. correspond to normal 80x25 text columns.
  438.  
  439.  
  440. VIEWGIP
  441.  
  442.   Also enclosed is VIEWGIP.EXE.
  443.  
  444.   ViewGIP will let you display files with GIP codes inside them.  It works
  445.   much like TYPE filename.ANS works.  Just type: VIEWGIP filename.GIP
  446.  
  447.   The only limitations are that the two SVGA modes won't work with this
  448.   viewer, and the maximum file size is 16k.
  449.  
  450.   The program will display the file, and then wait for you to hit a key.
  451.   For best viewing, I recommend you remove any "S0;" mode-to-normal you
  452.   have at the end of the file before displaying.
  453.  
  454.   While it is waiting for you to hit a key.  If you hit one of the
  455.   directional keys (arrows) this will show the coordinates of the point
  456.   at which the display end.  You can then continue to use the directional
  457.   keys to move about--identifying other locations.  This is very useful
  458.   when building menus/etc.  Hit any non-directional key to end.
  459.  
  460.  
  461. COMMIE
  462.  
  463.   Commie is available in a separate archive.  Your users can use this
  464.   program to see your GIP graphics.
  465.  
  466.  
  467. CONCLUSION
  468.  
  469.   All of the above stuff is already coded and done.  The only supported file
  470. │ display format right now is ".ICO" for icons, and .BMP for images--and I'm
  471. │ looking for source code to display ANY other graphic or sound formats.
  472.  
  473.   The stuff below still needs to be done, and will be available sometime in
  474.   the future:
  475.  
  476.     d coordinates (depth/3-D stuff)
  477.     GIFs/TIFs/PCXs/BMPs
  478.     sound files (VOC/MOD)
  479.     fonts (TrueType preferred)
  480.     circle's/elipses
  481.     etc.
  482.  
  483.   This is a very open-ended standard.  It's success and power depend on other
  484.   people supplying code for many of the things not done.  For instance, I
  485.   don't know 3-D graphics programming, the drivers for sound cards, or how to
  486.   display the various image file formats.  I'll teach myself and get it, but
  487.   reinventing wheels is not efficient.  So feel free to help.
  488.  
  489.  
  490.  
  491. I can be reached for comment/suggestions at:
  492.  
  493.     Immortality
  494.     414-643-1576
  495.     24 hrs.
  496.  
  497. Either log in, or just dump your NetMail on me.
  498.  
  499. John Rohner
  500. December 1994
  501.  
  502.  
  503.  
  504. I hereby release the GIP specifications, and any code specific only to 
  505. implementing the GIP specifications I include as an example, to the Public
  506. Domain for full, free, and uncredited distribution by other GIP-capable
  507. program authors. 
  508.  
  509. With the premediated hope that authors will simply import the code into their
  510. program to provide GIP support.  With a promise to never challenge nor
  511. discredit said authors, and that this Public Domain declaration shall be
  512. eternal.
  513.  
  514. This declaration does not extend to the various subroutines used to form the 
  515. example programs in which the GIP subroutines reside.
  516.  
  517.